home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ For TASM / THUNK95.PAK / DLL32.CPP < prev    next >
C/C++ Source or Header  |  1996-02-21  |  2KB  |  78 lines

  1. //----------------------------------------------------------------------------
  2. // Thunk95 example program
  3. // Copyright (c) 1996 by Borland International, All Rights Reserved
  4. //----------------------------------------------------------------------------
  5. // DllEntryPoint is responible for connecting to and disconnecting
  6. // from the 16-bit DLL. This can also be done from an executable,
  7. // by passing to xxxx_ThunkConnect32 a last parameter of
  8. // DLL_PROCCESS_ATTACH on connect and DLL_PROCESS_DETACH on disconnet.
  9. // Failure to disconnect from the 16-bit DLL leaves the 16-bit DLL in
  10. // memory after the process has completed.
  11.  
  12. #include <windows.h>
  13. #include "tools.h"
  14.  
  15. extern "C" BOOL WINAPI ThunkObj_ThunkConnect32( LPSTR pszDll16,
  16.                                            LPSTR pszDll32,
  17.                                            HINSTANCE hInst,
  18.                                            DWORD dwReason);
  19.  
  20. #pragma argsused
  21. BOOL WINAPI DllEntryPoint(HINSTANCE hInst, DWORD dwReason, LPVOID plvReserved)
  22.    {
  23.    bool connect = ThunkObj_ThunkConnect32("DLL16.DLL", "DLL32.DLL",
  24.                      hInst, dwReason);
  25.  
  26.    switch(dwReason)
  27.       {
  28.       case DLL_PROCESS_ATTACH:
  29.       case DLL_THREAD_ATTACH:
  30.          if(!connect)
  31.             {
  32.             return FALSE;
  33.             }
  34.       case DLL_PROCESS_DETACH:
  35.       case DLL_THREAD_DETACH:
  36.          if(!connect)
  37.             {
  38.             return FALSE;
  39.             }
  40.       }
  41.  
  42.    return TRUE;
  43.    }
  44.  
  45.  
  46. long PASCAL __export Multiply(int i, long l)
  47.    {
  48.    return Multiply16(i, l);
  49.    }
  50.  
  51. long double PASCAL __export MultiplyReal(double v1, double v2)
  52.    {
  53.    long double d;
  54.    MultiplyReal16(v1, v2, &d);
  55.    return d;
  56.    }
  57.  
  58. int PASCAL __export StrTableSize(void)
  59.    {
  60.    return StrTableSize16();
  61.    }
  62.  
  63. bool PASCAL __export StringLookup(int index, LPSTR bfr)
  64.    {
  65.    return StringLookup16(index, bfr);
  66.    }
  67.  
  68. int PASCAL __export EmpCount()
  69.    {
  70.    return EmpCount16();
  71.    }
  72.  
  73. bool PASCAL __export GetRecord(int index, EmpRecord* rec)
  74.    {
  75.    return GetRecord16(index, rec);
  76.    }
  77.  
  78.